import {
  q as s,
  p as R,
  ap as A,
  X as x,
  f as T,
  H as F,
  av as S,
  aw as H,
  k as u,
  l as P,
  az as q,
  as as l,
  aG as G,
  at as v,
  ay as X
} from "./index-30f27935.js";
import { f as _ } from "./finance-301595de.js";
function Y(i) {
  return (
    typeof i == "function" ||
    (Object.prototype.toString.call(i) === "[object Object]" && !X(i))
  );
}
function K(i) {
  const p = s([]),
    o = s(!0);
  s({}), R();
  const y = s(1),
    h = s(10),
    a = s([]),
    b = s(""),
    w = A("reload"),
    f = x({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    C = x({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    B = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 50 },
      { label: "订单ID", prop: "order_id", minWidth: 50 },
      {
        label: "订单编号",
        prop: "order_code",
        minWidth: 150,
        formatter: ({ order_code: e, operate: t }) =>
          u("div", null, [
            " ",
            u("div", null, [e]),
            u("div", null, [
              u(P("el-tag"), null, Y(t) ? t : { default: () => [t] })
            ])
          ])
      },
      { label: "用户名", prop: "user_name", minWidth: 80 },
      { label: "手机号", prop: "user_phone", minWidth: 100 },
      { label: "快递单号", prop: "track_code", minWidth: 100 },
      { label: "备注", prop: "content", minWidth: 80 },
      { label: "创建时间", prop: "create_time", minWidth: 100 }
    ],
    W = T(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function D(e) {
    q(e);
  }
  async function I(e) {
    const t = { role_id: e.role_id },
      c = JSON.stringify(t),
      m = { value: l.enc.Base64.stringify(l.enc.Utf8.parse(c)) },
      r = await G(m);
    r.code == 200
      ? (v("删除成功", { type: "success" }), w())
      : v(r.msg, { type: "error" });
  }
  function k() {}
  function z(e) {
    (h.value = e), g(void 0, e);
  }
  function J(e) {
    (y.value = e), g(e, void 0);
  }
  function L(e) {}
  function N(e) {
    (C.text = `正在加载第${e}页...`),
      (o.value = !0),
      S(600).then(() => {
        o.value = !1;
      });
  }
  async function U(e, t = []) {
    (a.value = []),
      (o.value = !0),
      (b.value = e.user_phone),
      t.map(V => {
        const j = V,
          M = new Date(j);
        a.value.push(
          M.toLocaleDateString("zh-CN", {
            year: "numeric",
            month: "2-digit",
            day: "2-digit"
          })
        );
      });
    const c = {
        page: 1,
        pagesize: h.value,
        content: "express",
        user_phone: e.user_phone,
        type: e.type,
        start: a.value[0],
        end: a.value[1]
      },
      d = JSON.stringify(c),
      r = { value: l.enc.Base64.stringify(l.enc.Utf8.parse(d)) },
      { data: n } = await _(r);
    (p.value = n.express.data),
      (f.total = n.express.total),
      setTimeout(() => {
        o.value = !1;
      }, 500);
  }
  async function g(e = y.value, t = h.value) {
    const c = {
        page: e,
        pagesize: t,
        user_phone: b.value,
        start: a.value[0],
        end: a.value[1],
        content: "express"
      },
      d = JSON.stringify(c),
      r = { value: l.enc.Base64.stringify(l.enc.Utf8.parse(d)) },
      n = await _(r);
    n.code === 200
      ? ((p.value = n.data.express.data),
        (f.total = n.data.express.total),
        setTimeout(() => {
          o.value = !1;
        }, 500))
      : v(n.msg, { type: "error" });
  }
  const O = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    F(() => {
      S().then(() => {
        const { setWatermark: e } = H(i.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        g();
    }),
    {
      loading: o,
      columns: B,
      dataList: p,
      pagination: f,
      buttonClass: W,
      formattedDate: a,
      onSearch: U,
      resetForm: O,
      handleaddUser: k,
      handleUpdate: D,
      handleDelete: I,
      handleSizeChange: z,
      handleCurrentChange: J,
      handleSelectionChange: L,
      onCurrentChange: N
    }
  );
}
export { K as useRole };
